package com.ruoyi.psi.purchase.order.domain;



import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;

/**
 * 采购订单表
 * psi_purchase_order
 * @author Drj 2021/6/28
 * 修改：lsy 2021.7.17
 */
public class PurchaseOrder extends BaseEntity {
    /**
     * 采购订单编号
     */
    @NotNull(message = "采购订单编号不能为空")
    @ApiModelProperty(value = "采购订单编号", required = true)
    private String purchaseOrderId;
    /**
     * 采购人编号
     */
    @ApiModelProperty(value = "采购人编号")
    private String staffId;
    /**
     * 采购人名称
     */
    @ApiModelProperty("采购人名称")
    @Excel(name = "采购人名称")
    private String staffName;
    /**
     * 供应商编号
     */
    @NotNull(message = "供应商编号不能为空")
    @ApiModelProperty(value = "供应商编号", required = true)
    private String supplierInfoId;
    /**
     * 供应商名称
     */
    @ApiModelProperty("供应商名称")
    private String supplierInfoName;
    /**
     * 采购总数量
     */
    @ApiModelProperty("采购总数量")
    private double purchaseNumberTotal;
    /**
     * 采购总额
     */
    @ApiModelProperty("采购总额")
    private double purchasePriceTotal;
    /**
     * 已入库数量
     */
    @ApiModelProperty("已入库数量")
    private double purchaseStorageNumberTotal;
    /**
     * 已入库金额
     */
    @ApiModelProperty("已入库金额")
    private double purchaseStoragePriceTotal;

    /**
     * 付款状态
     * 0-未付款 1-已付款
     */
    @ApiModelProperty("付款状态")
    private String paymentStatus;

    /**
     * 入库状态
     * 0-未入库 1-入库
     */
    @ApiModelProperty("入库状态")
    private String storageStatus;

    /**
     * 质检状态
     * 0-未检 1-已检
     */
    @ApiModelProperty("入库状态")
    private String inspectStatus;
    /**
     * 创建时间
     */
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp createTime;
    /**
     * 要求入库时间
     */
    @ApiModelProperty(value = "要求入库时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp requiredStorageTime;
    /**
     * 实际入库时间
     */
    @ApiModelProperty("实际入库时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp actualStorageTime;
    /**
     * 备注
     */
    @ApiModelProperty("备注")
    private String remark;
    /**
     * 是否审批
     */
    @ApiModelProperty("是否审批")
    private String approvalFlag;
    /**
     * 采购订单产品详细
     */
    private List<PurchaseOrderList> purchaseOrderLists;

    public List<PurchaseOrderList> getPurchaseOrderLists() {
        return purchaseOrderLists;
    }

    public void setPurchaseOrderLists(List<PurchaseOrderList> purchaseOrderLists) {
        BigDecimal bigDecimalPNT = new BigDecimal("0"); //采购总数量,purchaseNumberTotal-purchaseOrderNumber
        BigDecimal bigDecimalPPT = new BigDecimal("0"); //采购总额,purchasePriceTotal-purchaseOrderPrice
        BigDecimal bigDecimalPSNT = new BigDecimal("0"); //已入库数量,purchaseStorageNumberTotal-purchaseStorageNumber
        BigDecimal bigDecimalPSPT = new BigDecimal("0"); //已入库金额,purchaseStoragePriceTotal-purchaseStoragePrice
        for (int i = 0; i < purchaseOrderLists.size(); i++) {
            bigDecimalPNT = bigDecimalPNT.add(BigDecimal.valueOf(purchaseOrderLists.get(i).getPurchaseOrderNumber()));
            bigDecimalPPT = bigDecimalPPT.add(BigDecimal.valueOf(purchaseOrderLists.get(i).getPurchaseOrderPrice()));
            bigDecimalPSPT = bigDecimalPSPT.add(BigDecimal.valueOf(purchaseOrderLists.get(i).getPurchaseStoragePrice()));
            bigDecimalPSNT = bigDecimalPSNT.add(BigDecimal.valueOf(purchaseOrderLists.get(i).getPurchaseStorageNumber()));
        }
        setPurchaseNumberTotal(bigDecimalPNT.doubleValue());
        setPurchasePriceTotal(bigDecimalPPT.doubleValue());
        setPurchaseStorageNumberTotal(bigDecimalPSNT.doubleValue());
        setPurchaseStoragePriceTotal(bigDecimalPSPT.doubleValue());
        this.purchaseOrderLists = purchaseOrderLists;
    }

    public String getPurchaseOrderId() {
        return purchaseOrderId;
    }

    public void setPurchaseOrderId(String purchaseOrderId) {
        this.purchaseOrderId = purchaseOrderId;
    }

    public String getStaffId() {
        return staffId;
    }

    public void setStaffId(String staffId) {
        this.staffId = staffId;
    }

    public String getStaffName() {
        return staffName;
    }

    public void setStaffName(String staffName) {
        this.staffName = staffName;
    }

    public String getSupplierInfoId() {
        return supplierInfoId;
    }

    public void setSupplierInfoId(String supplierInfoId) {
        this.supplierInfoId = supplierInfoId;
    }

    public String getSupplierInfoName() {
        return supplierInfoName;
    }

    public void setSupplierInfoName(String supplierInfoName) {
        this.supplierInfoName = supplierInfoName;
    }

    public double getPurchaseNumberTotal() {
        return purchaseNumberTotal;
    }

    public void setPurchaseNumberTotal(double purchaseNumberTotal) {
        this.purchaseNumberTotal = purchaseNumberTotal;
    }

    public double getPurchasePriceTotal() {
        return purchasePriceTotal;
    }

    public void setPurchasePriceTotal(double purchasePriceTotal) {
        this.purchasePriceTotal = purchasePriceTotal;
    }

    public double getPurchaseStorageNumberTotal() {
        return purchaseStorageNumberTotal;
    }

    public void setPurchaseStorageNumberTotal(double purchaseStorageNumberTotal) {
        this.purchaseStorageNumberTotal = purchaseStorageNumberTotal;
    }

    public double getPurchaseStoragePriceTotal() {
        return purchaseStoragePriceTotal;
    }

    public void setPurchaseStoragePriceTotal(double purchaseStoragePriceTotal) {
        this.purchaseStoragePriceTotal = purchaseStoragePriceTotal;
    }

    public String getStorageStatus() {
        return storageStatus;
    }

    public void setStorageStatus(String storageStatus) {
        this.storageStatus = storageStatus;
    }

    @Override
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    public Timestamp getRequiredStorageTime() {
        return requiredStorageTime;
    }

    public void setRequiredStorageTime(Timestamp requiredStorageTime) {
        this.requiredStorageTime = requiredStorageTime;
    }

    public Timestamp getActualStorageTime() {
        return actualStorageTime;
    }

    public void setActualStorageTime(Timestamp actualStorageTime) {
        this.actualStorageTime = actualStorageTime;
    }

    @Override
    public String getRemark() {
        return remark;
    }

    @Override
    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getApprovalFlag() {
        return approvalFlag;
    }

    public void setApprovalFlag(String approvalFlag) {
        this.approvalFlag = approvalFlag;
    }

    public String getPaymentStatus() {
        return paymentStatus;
    }

    public void setPaymentStatus(String paymentStatus) {
        this.paymentStatus = paymentStatus;
    }

    public String getInspectStatus() {
        return inspectStatus;
    }

    public void setInspectStatus(String inspectStatus) {
        this.inspectStatus = inspectStatus;
    }

    @Override
    public String toString() {
        return "PurchaseOrder{" +
                "purchaseOrderId='" + purchaseOrderId + '\'' +
                ", staffId='" + staffId + '\'' +
                ", staffName='" + staffName + '\'' +
                ", supplierInfoId='" + supplierInfoId + '\'' +
                ", supplierInfoName='" + supplierInfoName + '\'' +
                ", purchaseNumberTotal=" + purchaseNumberTotal +
                ", purchasePriceTotal=" + purchasePriceTotal +
                ", purchaseStorageNumberTotal=" + purchaseStorageNumberTotal +
                ", purchaseStoragePriceTotal=" + purchaseStoragePriceTotal +
                ", paymentStatus='" + paymentStatus + '\'' +
                ", storageStatus='" + storageStatus + '\'' +
                ", inspectStatus='" + inspectStatus + '\'' +
                ", createTime=" + createTime +
                ", requiredStorageTime=" + requiredStorageTime +
                ", actualStorageTime=" + actualStorageTime +
                ", remark='" + remark + '\'' +
                ", approvalFlag='" + approvalFlag + '\'' +
                ", purchaseOrderLists=" + purchaseOrderLists +
                '}';
    }
}
